package nullby.omnia.adapter;

import nullby.omnia.R;
import nullby.omnia.db.DatabaseHelper;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Typeface;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class AdapterThemes extends CursorAdapter {

	private LayoutInflater inflater;
	private Typeface font;

	public AdapterThemes(Context context, Cursor c) {
		super(context, c);
		inflater = LayoutInflater.from(context);
		font = Typeface.createFromAsset(context.getAssets(), "font.ttf");
	}

	@Override
	public void bindView(View view, Context context, Cursor cursor) {
		view.setTag(cursor.getString(0));
		TextView tvName = (TextView) view.findViewById(R.id.tvName);
		tvName.setText(cursor.getString(1));
		tvName.setTypeface(font);

		TextView tvCount = (TextView) view.findViewById(R.id.tvCount);
		tvCount.setText(DatabaseHelper.get().getCountCard(cursor.getString(0)));
	}

	@Override
	public View newView(Context context, Cursor cursor, ViewGroup parent) {
		return inflater.inflate(R.layout.item_theme, parent, false);
	}

}
